/*
 * @Author: jimma0312 jimma0312@outlook.com
 * @Date: 2023-07-08 16:00:31
 * @LastEditors: Ma YuChen
 * @LastEditTime: 2023-08-02 16:57:52
 * @FilePath: \video-repeater-ctl-mcu\LT86101UXE\ctl_lt86101.h
 * @Description: 定义LT86101 HDMI 视频中继芯片的控制模块
 */
#ifndef CTL_LT86101_H
#define CTL_LT86101_H 

#include <gd32f10x_gpio.h>
#include "lt_global.h"

#define LT_RESET_PIN   GPIO_Pin_11
#define LT_RESET_PORT  GPIOA
#define LT_RESET_APBxClock_FUN      RCC_APB2PeriphClockCmd

#define LT86101UXE			0x70

#define  TX_SWING_200MHZ		0x50
#define  TX_SWING_300MHZ		0x50
#define  TX_SWING_600MHZ		0x60    /*0x20 */
#define  TX_TAP_SWING_200MHZ		0x00
#define  TX_TAP_SWING_300MHZ		0x43
#define  TX_TAP_SWING_600MHZ		0xc8    /*0x0F */
#define  Junior_TX_TAP_SWING_600MHZ		0xc8    /*0x0F */
#define  TX_PREEMPHASIS			0xb0
#define  TX_NOPREEMPHASIS		0xa0
#define     FREQ_DIV_200MHZ		(uint32_t) 0x030d40
#define     FREQ_DIV_300MHZ		(uint32_t) 0x053020

#define     CLK_CHANGE_MARGIN		(24 * 1024)      /*CLK_CHANGE_MARGIN*1KHz */
#define     CLK_ACTIVE_MIN_LIMIT	(16 * 1024)     /*CLK_ACTIVE_MIN_LIMIT should be lower than 25M(480P). */



/**
 * @description: 上电后，初始化lt86101芯片
 *               1.复位为低电平 延时 100ms
 *               2.复位为高电平 延时 100ms
 * 
 * @return {*}
 */
void lt86101_init(LT_GLOBAL* _lt_GlobalStruct);
void vStart_work(LT_GLOBAL* _lt_GlobalStruct);
void CLK_det(LT_GLOBAL* _lt_GlobalStructoid);
void vdClk_Stable_Config(LT_GLOBAL* _lt_GlobalStruct);
void vdPrintError( LT_GLOBAL* _lt_GlobalStruct );

void vdSet_Rx_HPD(LT_GLOBAL* _lt_GlobalStruct, ControlStatus state);

//void test_86101(void);

#endif //CTL_LT86101_H
